home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1421 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: mother.usf.edu!suntan!cdiaz
  2. From: "Carlos Diaz (CS)" <cdiaz@eng.usf.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: Keyboard input: C's equivalent to BASIC's Inkey$
  5. Date: Thu, 11 Jan 1996 21:39:33 -0500
  6. Organization: University of South Florida
  7. Message-ID: <Pine.SUN.3.91.960111212844.17033A@suntan>
  8. NNTP-Posting-Host: suntan.eng.usf.edu
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11. X-Sender: cdiaz@suntan
  12.  
  13. Hi! Can someone tell me what the C equivalent of BASIC's Inkey$ command 
  14. is? In particular, I'm looking to translate the following BASIC code to 
  15. C. It's the old, "wait for a key- if there is  no key do something else 
  16. then wait for a key, etc".
  17.  
  18. DO
  19.   DO WHILE k$ = ""  'As long as there is no key, keep waiting
  20.     k$=Inkey$
  21.     ' Additional statements to increment a counter, update and display a
  22.     ' clock with running seconds, etc, can go here.
  23.   LOOP
  24.   PRINT k$;         'Print the key that was just gotten
  25.   k$=""
  26. LOOP
  27.  
  28. It's the beginning of a customizable user input routine, and with some 
  29. modification can serve to program the keyboard to move a cursor around, 
  30. highlight menu selection, etc. Thank you for your help!
  31.  
  32. Sincerely,
  33. Carlos E. Diaz
  34.  
  35.